import numpy as np 
from numpy import NaN
from openpyxl import Workbook
from openpyxl import load_workbook
import pathlib
import os
import sqlite3
from inc import *
import time

r=cur.execute("select * from bj")
bj=[]
for i in r.fetchall():  # 班级列表
    bj.append(i[0])
bj.append("全校")
def sqlbj(sql,bj):
    if(bj=="全校"):
        return sql
    else:
        if(sql.find("where")==-1 and sql.find("WHERE")):
            return sql + "where  \"班级\"=\"{bj}\"".format(bj=bj)
        else:
            return sql + "and  \"班级\"=\"{bj}\"".format(bj=bj)

##########################################3


data=getsortdata()
for i,v in enumerate(data):
    print("{0[name]: <6s}\t{0[zf]}\t{0[bj]}\t{0[bmc]}\t{0[xmc]}".format(v))


print(countfsd(fsd))
data={}


f=['总人数','及格人数','优秀人数']
for i in f :
    t=[]
    for n in bj:
        t.append(counts(i,n))
    data[i]=np.array(t)
data['及格率']=np.true_divide(data['及格人数'],data['总人数'])
data['优秀率']=np.true_divide(data['优秀人数'],data['总人数'])
print(data)

f={'及格率':"{x:.2%}",'优秀率':"{x:.2%}",'及格人数':"{x:.0f}",'优秀人数':"{x:.0f}",'总人数':"{x:.0f}"}
gethtml(data,f)
getDetailed()
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))